package com.jilin.library.mapper;

import com.jilin.library.entity.Reader;
import org.apache.ibatis.annotations.*;
import java.util.List;

@Mapper
public interface ReaderMapper {
    @Select("SELECT * FROM reader")
    List<Reader> findAll();
    
    @Select("SELECT * FROM reader WHERE id = #{id}")
    Reader findById(Integer id);
    
    @Insert("INSERT INTO reader(name, card_number, phone, email) " +
            "VALUES(#{name}, #{cardNumber}, #{phone}, #{email})")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    int insert(Reader reader);
    
    @Update("UPDATE reader SET name = #{name}, phone = #{phone}, email = #{email} " +
            "WHERE id = #{id}")
    int update(Reader reader);
    
    @Delete("DELETE FROM reader WHERE id = #{id}")
    int delete(Integer id);
} 